#include "stdafx.h"
#include "SkydomeShader.h"

int SkydomeShader::Init(char *fileVertexShader, char *fileFragmentShader)
{
	GLenum err;
	vertexShader = esLoadShader(GL_VERTEX_SHADER, fileVertexShader);
	err = glGetError();
	if ( vertexShader == 0)
		return -1;

	fragmentShader = esLoadShader(GL_FRAGMENT_SHADER, fileFragmentShader);
	err = glGetError();
	if ( fragmentShader == 0)
	{
		glDeleteShader(vertexShader);
		return -2;
	}

	program = esLoadProgram(vertexShader, fragmentShader);
	err = glGetError();

	VertexPosition = glGetAttribLocation(program, "a_vertPosL");
	WVPMatrix = glGetUniformLocation(program, "u_wvpMatrix");
	Texture = glGetUniformLocation(program, "u_texture");

	return 0;
}

SkydomeShader::~SkydomeShader()
{
	glDeleteProgram(program);
	glDeleteShader(vertexShader);
	glDeleteShader(fragmentShader);
}